<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<script>

    // 同步代码
    console.log('0');

    // 宏任务
    setTimeout(function () {
        console.log('1');
    }, 0);

    // 微任务
    Promise.resolve()
        .then(function () {
            console.log('2');
        })
        .then(function () {
            console.log('3');
        });

    // 同步代码
    console.log('4');
</script>
</body>
</html>
